#include "qobjectlistwidget.h"

#include "qobjectlistview.h"

#include "../../libs/corelib/styledbar.h"

#include <QVBoxLayout>
#include <QLabel>

QObjectListWidget::QObjectListWidget(QWidget *parent) :
    QWidget(parent),
    m_objectList(new QObjectListView),
    m_styledBar(new CORELIB::StyledBar)
{
    QVBoxLayout *l=new QVBoxLayout;
    l->setMargin(0);
    l->setSpacing(0);

    l->addWidget(m_styledBar);
    l->addWidget(m_objectList);

    this->setLayout(l);

    QLabel* label=new QLabel(tr("Object List"));
    label->setStyleSheet("color:rgb(255,255,255);");
    QVBoxLayout *layout=new QVBoxLayout;
    layout->setMargin(5);
    layout->addWidget(label);
    m_styledBar->setLayout(layout);

    connect(m_objectList,SIGNAL(selectSignal(QWidget*)),this,SIGNAL(widgetSelect(QWidget*)));
    connect(this,SIGNAL(formAddSignal(QWidget*)),m_objectList,SLOT(formAdd(QWidget*)));
    connect(this,SIGNAL(addWidgetSignal(QWidget*,int)),m_objectList,SLOT(addWidget(QWidget*,int)));
    connect(this,SIGNAL(clear_object_list()),m_objectList,SLOT(clear_list()));
    connect(this,SIGNAL(widgetRemove(QWidget*)),m_objectList,SLOT(widgetRemove(QWidget*)));
}

void QObjectListWidget::updateObject()
{
}

void QObjectListWidget::selectWidget(QWidget *wid)
{
    disconnect(m_objectList,SIGNAL(selectSignal(QWidget*)),this,SIGNAL(widgetSelect(QWidget*)));
    m_objectList->selectWidget(wid);
    connect(m_objectList,SIGNAL(selectSignal(QWidget*)),this,SIGNAL(widgetSelect(QWidget*)));
}
